package com.yidu.t299.service.lzy.impl;

import com.yidu.t299.dao.lzy.MarketaMapper;
import com.yidu.t299.domain.lzy.Market;
import com.yidu.t299.service.lzy.MarketaBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class MarketaBizImpl implements MarketaBiz {
    @Autowired
    private MarketaMapper marketMapper;



    @Override
    public int deleteByPrimaryKey(Integer planId) {
        return marketMapper.deleteByPrimaryKey(planId);
    }

    @Override
    public int insert(Market market) {
        return marketMapper.insert(market);
    }

    @Override
    public Market selectByPrimaryKey(Integer planId) {
        return marketMapper.selectByPrimaryKey(planId);
    }


    @Override
    public List<Market> selectByPage(int rows, int page, String condition) {
        return marketMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return marketMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(Market market) {
        return marketMapper.updateByPrimaryKey(market);
    }

    @Override
    public String getCondition(Market record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        if (record.getPlanId() != null) {
            condition += " and plan_id = " + record.getPlanId();
        }
        if (record.getExecuteState() != null && record.getExecuteState().trim().length() != 0) {
            condition += " and execute_state like '%" + record.getExecuteState() + "%'";
        }
        // 返回条件字符串
        return condition;
    }

    @Override
    public int selectBySourceName(String sourceName) {
        return Integer.parseInt(marketMapper.selectBySourceName(sourceName));
    }


}
